<?php

class MathUtils {

    public static function division($dividend, $divisor, $decimalHouses) {
        if( $dividend == 0 || $divisor == 0 ) {
            return 0;
        }
        return number_format($dividend/$divisor, $decimalHouses, '.', '');
    }

    public static function percentage($total, $percent, $decimalHouses) {
        if( $total == 0 || $percent == 0 ) {
            return 0;
        }
        return number_format($percent * $total / 100, $decimalHouses, '.', '');
    }

    public static function getPercent($total, $value) {
        if( $total == 0 || $value == 0 ) {
            return 0;
        }
        return number_format($value * 100 / $total, 0, '.', '');
    }

    public static function money($StValue, $StSimbol = 'R$') {
        return $StSimbol . ' ' . number_format($StValue, 2, ',', '.');
    }

    public static function moneyToDouble($StMoney) {
        $StMoneyWithoutAssign = str_replace('R$ ', '', $StMoney);
        return str_replace(',', '.', $StMoneyWithoutAssign);
    }
}

?>
